<template>
    <bi-select 
    icon="fa-cube"
    :loading ="loading"
    :disabled="disabled"
    :placeholder="placeholder"
    v-model ="value"
    :clear="true"
    >
      <bi-select-option v-for="(item,index) in list" :key="item.model_id" :value="item.model_id" :label="item.title" ></bi-select-option>
    </bi-select>
</template>
<script>
import fieldMixin from  '@@/admin/assets/bi-plug/fieldMixin.js';
export default{
    mixins:[fieldMixin],
    data(){
        return {
            list:[],
            item:{},
            loading:false
        }
    },
    props:{
        type:{
            type:String,
            default:''
        }
    },
    methods:{
        refresh(){
            this.loading = true;
            this.$ajax({
                url:this.$url({app:'web','controller':'admin.model','action':'option'}),
                data:{
                    type:this.type
                },
                success:(data)=>{
                    this.list = data;
                    this.$user.setLocalStorage('web-model-'+this.type,data,60);
                    this.loading = false;
                }
            });
        },
        getData(){
            return this.item;
        }
    },
    mounted(){
        if (this.type==''){
            console.error('参数类型不能为空');
        }else{

            let list = this.$user.getLocalStorage('web-model-'+this.type);
            if (list){
                this.list = list;
             }else{
                this.refresh();
            }

        }


    }
}
</script>